﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace DuAnNH
{
    class CLs_ThongKe
    {
        public static DataTable LayDSTK_Ngay(string ngay)
        {
            try
            {
                string sql = "select MaTD,TenTD,Sum(Soluong) as SoLuong,sum(Tien) as Tien from ChiTietHoaDon where NgayTT='" + ngay + "' group by MaTD,TenTD";
                SqlDataAdapter adap = new SqlDataAdapter(sql, Coso.con);
                DataTable tb = new DataTable();
                adap.Fill(tb);
                return tb;
            }
            catch
            {
                return null;
            }
        }
        public static DataTable LayDSTK_Thang(string thang,string nam)
        {
            try
            {
                string sql = "select MaTD,TenTD,Sum(Soluong) as SoLuong,sum(Tien) as Tien from ChiTietHoaDon where month(NgayTT)='" + thang + "' and year(NgayTT)='" + nam + "' group by MaTD,TenTD";
                SqlDataAdapter adap = new SqlDataAdapter(sql, Coso.con);
                DataTable tb = new DataTable();
                adap.Fill(tb);
                return tb;
            }
            catch
            {
                return null;
            }
        }
        public static DataTable LayDSTK_KhoangNgay(string ngaybegin,string ngayend)
        {
            try
            {
                string sql = "select MaTD,TenTD,Sum(Soluong) as SoLuong,sum(Tien) as Tien from ChiTietHoaDon where NgayTT>='" + ngaybegin + "' and NgayTT <='" + ngayend + "' group by MaTD,TenTD";
                SqlDataAdapter adap = new SqlDataAdapter(sql, Coso.con);
                DataTable tb = new DataTable();
                adap.Fill(tb);
                return tb;
            }
            catch
            {
                return null;
            }
        }
    }
}
